﻿using Face8280WebSocketServer.Interface;
using Face8280WebSocketServer.Model;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json.Serialization;

namespace Face8280WebSocketServer.Service
{
    public class RecordService : BaseService, IRecordService
    {
        public RecordService(DbContext context) : base(context)
        {

        }

        public bool AddRecord(DriveRecord record)
        {
            AddUserLog("出入记录", $"新增出入记录: {record.ToJson()} ");
            record = Insert<DriveRecord>(record);
            

            return true;
        }

        public void ClearRecord()
        {
            Excute("Delete from FaceRecord");
            AddUserLog("出入记录", "清空所有出入记录");
            Commit();
        }
    }
}
